home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS03.ADF
/
C
/
chop.c
< prev
next >
Wrap
Text File
|
1986-04-02
|
3KB
|
80 lines
/**************************************************************************
* filefix vers 1.0 - designed to run under CLI only *
* *
* (c) 1986 by Techni Soft - Technical Software for the AMIGA *
* *
* 24 hour data line and BBS (801) 264-8290 *
* *
* This trivial program released to the public domain 05Jan86 *
* *
**************************************************************************/
#include <exec/types.h>
#include <stdio.h>
#include <ctype.h>
#include <libraries/dos.h>
main(argc,argv)
int argc;
char *argv[];
{
FILE *inp,*outp; /* input and output file pointers */
int filesize, /* size to chop to */
r; /* i/o character and status */
LONG count=0; /* count of bytes output */
/*****************************
* see if we got enough args *
*****************************/
if( argc != 3 )
{
printf("\n\nusage: filefix <fromfile> <tofile>\n\n",argc);
exit(FALSE);
}
/********************************************************************
* attempt to open the input and (create if needed) the output file *
********************************************************************/
if( (inp = fopen(argv[1], "r")) == NULL)
{
printf("\n\nerror opening input file [%s]\n\n ",argv[1]);
exit(FALSE);
}
if( (outp = fopen(argv[2], "w")) == NULL)
{
printf("\n\nerror opening output file [%s]\n\n",argv[2]);
fclose(inp);
exit(FALSE);
}
printf("\nenter file size :");
scanf("%d",&filesize);
printf("\nchopping file to %d bytes\n",filesize);
/***********************************************************
* read input and write output for the specified number *
* of bytes. Notice that NO error checking is done here *
* except for EOF condition on input file.... *
* *
* note that an assumption is also being made that the *
* two I/O function are feeding us raw characters (i.e *
* a CR/LF pair is NOT being xlated to a single \n char) *
***********************************************************/
while(( ( r = fgetc(inp)) != EOF) && ++count <= filesize)
{
fputc( r, outp);
if(! count % 1024)
printf("+");
if(! count % 10240)
printf("\n");
}
fclose(inp);
fclose(outp);
}